package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.LdapServer;
import org.deadline.repository.config.LdapServerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class LdapServerServiceImpl implements LdapServerService {

	@Autowired
    LdapServerRepository ldapServerRepository;

	public long countAllLdapServers() {
        return ldapServerRepository.count();
    }

	public void deleteLdapServer(LdapServer ldapServer) {
        ldapServerRepository.delete(ldapServer);
    }

	public LdapServer findLdapServer(Long id) {
        return ldapServerRepository.findOne(id);
    }

	public List<LdapServer> findAllLdapServers() {
        return ldapServerRepository.findAll();
    }

	public List<LdapServer> findLdapServerEntries(int firstResult, int maxResults) {
        return ldapServerRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveLdapServer(LdapServer ldapServer) {
        ldapServerRepository.save(ldapServer);
    }

	public LdapServer updateLdapServer(LdapServer ldapServer) {
        return ldapServerRepository.save(ldapServer);
    }
}
